﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinQ_DTO;
//MinhKhoa
namespace DAO
{
    public class LoaiTrangTriDAO
    {
        public List<shop_loaitrangtri> LayTatCaLoaiTrangTri()
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var products = from a in EFashionDB.shop_loaitrangtris select a;
            return products.ToList();
        }
        public void ThemLoaiTrangTri(shop_loaitrangtri AddObject)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            EFashionDB.shop_loaitrangtris.InsertOnSubmit(AddObject);
            EFashionDB.SubmitChanges();
        }
        public void XoaLoaiTrangTri(int Ma)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var ListResultQuery = from a in EFashionDB.shop_loaitrangtris
                                  where a.MaLoaiTrangTri == Ma
                                  select a;
            shop_loaitrangtri Result = ListResultQuery.Single();
            EFashionDB.shop_loaitrangtris.DeleteOnSubmit(Result);
            EFashionDB.SubmitChanges();
        }
        public void CapNhatLoaiTrangTri(int Ma, shop_loaitrangtri EditObject)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var ListResultQuery = from a in EFashionDB.shop_loaitrangtris
                                  where a.MaLoaiTrangTri == Ma
                                  select a;
            shop_loaitrangtri Result = ListResultQuery.Single();
            Result.TenLoaiTrangTri = EditObject.TenLoaiTrangTri;
            EFashionDB.SubmitChanges();
        }
    }
}
